﻿using System.Collections.Generic;
using System.Linq;

namespace Bilibili.Model.Dynamic
{
    public sealed class DynamicFeedNew
    {
        public List<EmojiDetails> emoji_details { get; set; }
        public long doc_id { get; set; }
        public long upload_timestamp { get; set; }
        public long upload_time { get; set; }
        public long id { get; set; }
        public DynamicFeedNew item { get; set; }
        public DynamicFeedNew user { get; set; }
        public long uid { get; set; }
        public string head_url { get; set; }
        public string name { get; set; }
        public string content { get; set; }
        public long dynamic_id { get; set; }
        private string _description;
        public string description
        {
            get
            {
                if (_description == null || _description == "")
                {
                    if (content != null && content.Length != 0)
                        return content;
                    else
                        return title;
                }
                else
                    return _description;
            }
            set { _description = value; }
        }
        public string at_control { get; set; }
        public string title { get; set; }
        public int comment_count { get; set; }
        public int vote_count { get; set; }
        public int pictures_count { get; set; }
        public string uname { get; set; }
        private List<Pictures> _pictures;
        public List<Pictures> pictures
        {
            get
            {
                if (_pictures != null)
                    _pictures.ForEach(x => x.c = pictures_count);
                return _pictures;
            }
            set { _pictures = value; }
        }
        public List<Pictures> pics
        {
            get
            {
                if (pictures == null)
                    return null;
                else
                {
                    if (pictures.Count <= 9)
                        return pictures;
                    else
                    {
                        var ls = pictures.Take(9).ToList();
                        ls.Last().count = pictures.Count;
                        return ls;
                    }
                }
            }
        }
        public List<Pictures> showpictures { get; set; }
    }
}